﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Snowdreamist.Collection;

namespace SNSpirit.Domain
{
    [Serializable]
    public abstract class DomainEntity : INotifyPropertyChanged
    {
        /// <summary>
        /// Create collection
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static ConcurrentCollection<T> CreateCollection<T>()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Create collection
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static ConcurrentCollection<T> CreateCollection<T>(IEnumerable<T> collection)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Notify this entity has been updated
        /// </summary>
        public virtual void NotifyUpdated()
        {
            this.OnUpdated();
        }

        /// <summary>
        /// Fire event PropertyChanged
        /// </summary>
        /// <param name="name"></param>
        protected virtual void OnPropertyChanged(string name)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(name));
        }

        /// <summary>
        /// Fire event Updated
        /// </summary>
        protected virtual void OnUpdated()
        {
            if (this.Updated != null)
                this.Updated(this, new EventArgs());
        }

        /// <summary>
        /// Fire when entity updated
        /// </summary>
        public event EventHandler Updated;
        /// <summary>
        /// Notify property changed
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
    }
}